/**
 * 
 */
package uk.ac.ebi.velvet.model;



/**
 * @author mhaimel
 *
 */
public enum Strand {

	UNKOWN('?','U','0',null),
	FWD('+','F','1',true),
	REV('-','R','2',false);
	
	private final char sym;
	private final char solexa;
	private final char maq;
	private final Boolean bitValue; 

	private Strand(char sym, char solexa, char maq,Boolean bitValue) {
		this.sym = sym;
		this.solexa = solexa;
		this.maq = maq;
		this.bitValue = bitValue;
	}
	
	public static Strand getStrand(char c){
		Strand found = null;
		for(Strand str : values()){
			if(str.sym == c){
				found = str;
				break;
			} else if(str.solexa == c){
				found = str;
				break;
			} else if(str.maq == c){
				found = str;
				break;
			}
		}
		return found;
	}
	
	public static Strand getStrand(Boolean bitVal){
		Strand found = null;
		if(bitVal == null){
			return Strand.UNKOWN;
		}
		for(Strand str : new Strand[]{FWD,REV}){
			if(bitVal.equals(str.bitValue)){
				found = str;
				break;
			}
		}
		return found;
	}
	
	public Strand getOpposite(){
		if(this.equals(FWD)){
			return REV;
		} else {
			return FWD;
		}
	}
	
	public char getSymbol(){
		return sym;
	}
	
	public char getSolexaExt(){
		return solexa;
	}
	
	public char getMaqExt(){
		return maq;
	}

	public Boolean getBitValue() {
		return bitValue;
	}
	
}
